{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(426, 30)\n",
      "(143, 30)\n",
      "Epoch 1/10\n",
      "14/14 [==============================] - 1s 9ms/step - loss: 41.3660 - accuracy: 0.5446\n",
      "Epoch 2/10\n",
      "14/14 [==============================] - 0s 11ms/step - loss: 1.8780 - accuracy: 0.6972\n",
      "Epoch 3/10\n",
      "14/14 [==============================] - 0s 9ms/step - loss: 0.5126 - accuracy: 0.8310\n",
      "Epoch 4/10\n",
      "14/14 [==============================] - 0s 9ms/step - loss: 0.2878 - accuracy: 0.8873\n",
      "Epoch 5/10\n",
      "14/14 [==============================] - 0s 17ms/step - loss: 0.2890 - accuracy: 0.8944\n",
      "Epoch 6/10\n",
      "14/14 [==============================] - 0s 11ms/step - loss: 0.2242 - accuracy: 0.9131\n",
      "Epoch 7/10\n",
      "14/14 [==============================] - 0s 10ms/step - loss: 0.2597 - accuracy: 0.8967\n",
      "Epoch 8/10\n",
      "14/14 [==============================] - 0s 13ms/step - loss: 0.3301 - accuracy: 0.8850\n",
      "Epoch 9/10\n",
      "14/14 [==============================] - 0s 9ms/step - loss: 0.3261 - accuracy: 0.8803\n",
      "Epoch 10/10\n",
      "14/14 [==============================] - 0s 10ms/step - loss: 0.2720 - accuracy: 0.8920\n",
      "5/5 - 0s - loss: 0.3346 - accuracy: 0.8601\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "[0.33458197116851807, 0.8601398468017578]"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#!/usr/bin/python\n",
    "# -*- coding: UTF-8 -*-\n",
    "\n",
    "import os\n",
    "\n",
    "from sklearn.datasets import load_breast_cancer\n",
    "from sklearn.model_selection import train_test_split\n",
    "from tensorflow.keras.layers import Dense\n",
    "from tensorflow.keras.models import Sequential\n",
    "from tensorflow.keras.optimizers import SGD\n",
    "\n",
    "os.environ[\"TF_CPP_MIN_LOG_LEVEL\"] = \"3\"  # or any {'0', '1', '2'}\n",
    "\n",
    "X, y = load_breast_cancer(return_X_y=True)\n",
    "X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=0)\n",
    "\n",
    "print(X_train.shape)\n",
    "print(X_test.shape)\n",
    "\n",
    "model = Sequential()\n",
    "model.add(Dense(64, activation=\"relu\"))\n",
    "model.add(Dense(64, activation=\"relu\"))\n",
    "model.add(Dense(1, activation=\"sigmoid\"))\n",
    "model.compile(optimizer=SGD(0.001),\n",
    "              loss=\"binary_crossentropy\",\n",
    "              metrics=[\"accuracy\"],\n",
    "              )\n",
    "\n",
    "model.fit(X_train, y_train, epochs=10)\n",
    "model.evaluate(X_test, y_test, verbose=2)\n"
   ]
  }
 ],
 "metadata": {
  "interpreter": {
   "hash": "e7370f93d1d0cde622a1f8e1c04877d8463912d04d973331ad4851f04de6915a"
  },
  "kernelspec": {
   "display_name": "Python 3.9.7 64-bit",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.7"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
